2020-2021 Sunseeker Telemetry and Lighting System
dac12_a_ex4_grouped.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
33 //MSP430F66x Demo - DAC12_A_0 & DAC12_A_1 grouped, positive ramp on DAC12_A_0 and
34 //negative ramp on DAC12_A_1, high settling speed/current.
68 //******************************************************************************
69 
70 #include "driverlib.h"
71 
72 void main (void)
73 {
74  uint16_t dataToConvert = 0;
75 
76  //Stop Watchdog Timer
77  WDT_A_hold(WDT_A_BASE);
78 
79  /*
80  * Initialize DAC12_A_0
81  * Multiply Vout by 1
82  * Use high settling speed/current,
83  * Auto trigger when data is set as,
84  * long as conversions are enabled
85  */
86  DAC12_A_initParam param0 = {0};
87  param0.submoduleSelect = DAC12_A_SUBMODULE_0;
88  param0.outputSelect = DAC12_A_OUTPUT_1;
89  param0.positiveReferenceVoltage = DAC12_A_VREF_AVCC;
90  param0.outputVoltageMultiplier = DAC12_A_VREFx1;
91  param0.amplifierSetting = DAC12_A_AMP_HIGHIN_HIGHOUT;
92  param0.conversionTriggerSelect = DAC12_A_TRIGGER_ENC;
93  DAC12_A_init(DAC12_A_BASE, &param0);
94 
95  /*Initialize DAC12_A_1
96  * Choose P6.7 as output
97  * Use AVcc as Vref+
98  * Multiply Vout by 1
99  * Use high settling speed/current
100  * Auto trigger when data is set as long as conversions are enabled
101  */
102  DAC12_A_initParam param1 = {0};
103  param1.submoduleSelect = DAC12_A_SUBMODULE_1;
104  param1.outputSelect = DAC12_A_OUTPUT_1;
105  param1.positiveReferenceVoltage = DAC12_A_VREF_AVCC;
106  param1.outputVoltageMultiplier = DAC12_A_VREFx1;
107  param1.amplifierSetting = DAC12_A_AMP_HIGHIN_HIGHOUT;
108  param1.conversionTriggerSelect = DAC12_A_TRIGGER_ENC;
109  DAC12_A_init(DAC12_A_BASE, &param1);
110 
111 
112  //Group both DAC12_A's to sync output
113  DAC12_A_enableGrouping(DAC12_A_BASE);
114 
115  //Calibrate output buffer for DAC12_A_0
116  DAC12_A_calibrateOutput(DAC12_A_BASE,
117  DAC12_A_SUBMODULE_0);
118 
119  //Calibrate output buffer for DAC12_A_0
120  DAC12_A_calibrateOutput(DAC12_A_BASE,
121  DAC12_A_SUBMODULE_1);
122 
123  //Enable Conversions for both DAC12_A_0 and DAC12_A_1
124  DAC12_A_enableConversions(DAC12_A_BASE,
125  DAC12_A_SUBMODULE_0);
126  DAC12_A_enableConversions(DAC12_A_BASE,
127  DAC12_A_SUBMODULE_1);
128 
129  for (;;)
130  {
131  dataToConvert++;
132 
133  //Set data for DAC12_A_0, which will not latch because it is grouped
134  DAC12_A_setData(DAC12_A_BASE,
135  DAC12_A_SUBMODULE_0,
136  dataToConvert);
137 
138  //Set data for DAC12_A_1, which will latch both DAC's data buffers
139  DAC12_A_setData(DAC12_A_BASE,
140  DAC12_A_SUBMODULE_1,
141  ~(dataToConvert));
142  __no_operation();
143  }
144 }
145 
void main(void)
__no_operation()